SolarRadiation Module

History

current version 1.1 - 16th June 2021

version date comment
1.0 19/May/2021 Original code
1.1 26/Jun/2021 added net radiation computation

License

license: GNU GPL http://www.gnu.org/licenses/

Module Description

Module to manage solar radiation with arbitrary time cumulation



Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: dtRadiation = 0

cumulation deltat

type(grid_real), public :: netRadiation

incoming and outcoming shortwave and longwave radiation [W/m2]

type(grid_real), public :: netRadiationFAO

net radiation of FAO reference grass with albedo = 0.23

type(grid_real), public :: radiation

[W/m2]

type(ObservationalNetwork), public :: radiometers

radiation stations network

real(kind=float), private, parameter :: MISSING_DEF_REAL = -9999.9
type(grid_real), private :: aspect

terreain aspect to be used to modify interpolated data [radians]

real(kind=float), private :: azimuth(16)
real(kind=float), private :: cellsizeInterpolation

spatial resolution of interpolated grid

integer(kind=short), private :: dtGrid

dt of imported field

integer(kind=short), private :: elevationDrift

1 = use elevation to modify interpolated data

integer(kind=short), private :: export

activates grid exporting

type(CRS), private :: exportGridMapping
integer(kind=short), private :: export_dt

time between two exportations

integer(kind=short), private :: export_epsg

coordinate reference system of exported grid

character(len=1000), private :: export_file

name of exported file

character(len=1000), private :: export_file_net

name of exported net radiation file

character(len=1000), private :: export_file_var

name of exported variance grid

integer(kind=short), private :: export_format

1 = esri_ascii, 2 = esri_binary, 3 = netcdf

character(len=1000), private :: export_path

folder where to put exported grids

type(DateTime), private :: export_start

time and date to start exporting

type(DateTime), private :: export_stop

time and date to stop exporting

type(grid_real), private :: exportedGrid
type(grid_real), private :: exportedGridNet
type(grid_real), private :: exportedGridVar
character(len=300), private :: fileGrid

file containing grids

integer(kind=short), private :: fileunit

unit of file containing data

type(grid_real), private :: grid_devst

standard deviation of kriging interpolation

integer(kind=short), private :: i

loop index

real(kind=float), private :: idw_power

power to be used with IDW

type(grid_real), private :: interpolatedMap(3)

1 = map for thiessen, 2 = map for idw, 3 = map for kriging

integer(kind=short), private :: interpolationMethod

method to spatial interpolate site data

integer(kind=short), private :: interpolationMethod_assignment

method to assign spatial interpolation ! 1 = one method for the entire domain, 2 = a map with interpolation method codes

type(grid_integer), private :: interpolationMethod_map
integer(kind=short), private :: interpolationMethod_vector(3)

defines active interpolation methods

integer(kind=short), private :: j

loop index

integer(kind=short), private :: krige_anisotropy

considers anisotropy, default = 0 excludes anisotropy

integer(kind=short), private :: krige_lags

number of lags for semivariogram. if undefined or set to 0 default to 15

real(kind=float), private :: krige_maxlag

maximum distance to be considered for semivariogram assessment. If undefined or set to 0, it is computed automatically

integer(kind=short), private :: krige_var

when set to 1 a grid of kriging variance is generated and exported if export option is active, default to 0

integer(kind=short), private :: krige_varmodel

1 = spherical, 2 = exponential, 3 = gaussian, 0 = automatic fitting. default to 2

logical, private :: needConversion
integer(kind=short), private :: neighbors

number of closest data to use for interpolation

real(kind=float), private :: offset_value

offset to apply to final map

real(kind=float), private :: scale_factor

scale factor to apply to final map

type(grid_real), private :: shadowGrid

shadow grid 1 = shadow, 0 = no shadow

type(grid_real), private :: slope

terreain slope to be used to modify interpolated data [radians]

type(DateTime), private :: timeNew

time when new data must be read

type(DateTime), private :: timeNewExport

time when new exporting must occur

integer(kind=short), private :: timezone

local timezone

real(kind=float), private :: valid_prcn

when data from several time steps are read, this is the minimum percentage (0-1) of valid data that must be prresent to consider valid the aggregated value.

type(ViewingAngle), private, ALLOCATABLE :: viewangle(:,:)

raster of maximum viewing angles


Derived Types

type, public ::  ViewingAngle

Components

Type Visibility Attributes Name Initial
real(kind=float), public :: angle(16)

Functions

private function OpticalDepth(time, lat, z) result(s)

Compute tthe atmospheric optical depth

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time
real(kind=float), intent(in) :: lat
real(kind=float), intent(in) :: z

Return Value real(kind=float)

optical depth

private function SolarAzimuth(time, lat) result(az)

Compute azimuth angle of the Sun's position in the north-clockwise convention

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time
real(kind=float), intent(in) :: lat

Return Value real(kind=float)

private function SolarDeclination(time) result(sdec)

Compute solar declination. The declination of the sun is the angle between the equator and a line drawn from the centre of the Earth to the centre of the sun.

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time

Return Value real(kind=float)

private function SolarHourAngle(time) result(w)

Compute the hour angle. the solar hour angle is an expression of time, hour angle is 0.000 degree, with the time before solar noon expressed as negative degrees, and the local time after solar noon expressed as positive degrees. For example, at 10:30 AM local apparent time the hour angle is -22.5 degree (15 degree per hour times 1.5 hours before noon).

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time

Return Value real(kind=float)

private function SunElevationAngle(time, lat) result(sea)

Compute the sun elevation angle

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time
real(kind=float), intent(in) :: lat

Return Value real(kind=float)


Subroutines

public subroutine SolarRadiationInit(ini, mask, dtMeteo, tstart, dem, dem_loaded, albedo_loaded, dtTemperature, dtRelHumidity)

Initialize solar radiation

Arguments

Type IntentOptional Attributes Name
type(IniList), intent(in) :: ini
type(grid_integer), intent(in) :: mask

defines interpolation extent

integer(kind=short), intent(in) :: dtMeteo

deltat of meteo data reading

type(DateTime), intent(in) :: tstart

initial time

type(grid_real), intent(in) :: dem

digital elevation model to be used to modify interpolated data

logical, intent(in) :: dem_loaded

true if dem has been loaded

logical, intent(in) :: albedo_loaded

true if dem has been loaded

integer(kind=short), intent(in) :: dtTemperature

delta time temperature

integer(kind=short), intent(in) :: dtRelHumidity

delta time relative humidity

public subroutine SolarRadiationRead(time, dem, albedo, temp, relHum)

Read radiation data

Read more…

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time

current time

type(grid_real), intent(in) :: dem

used to apply drift of station data

type(grid_real), intent(in) :: albedo

used to apply drift of radiation site data

type(grid_real), intent(in) :: temp

air temperature (degree celsius)

type(grid_real), intent(in) :: relHum

air relative humidity (0-100)

private subroutine CastShadow(az, sunHeight, view, grid)

Compute shadow grid

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: az
real(kind=float), intent(in) :: sunHeight
type(ViewingAngle), intent(in) :: view(:,:)
type(grid_real), intent(inout) :: grid

private subroutine ComputeNetRadiation(cfc, alb, short, hum, temp, netRad)

Compute net radiation

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: cfc

cloudiness factor complement

real(kind=float), intent(in) :: alb

albedo

real(kind=float), intent(in) :: short

shortwave radiation (W/m2)

real(kind=float), intent(in) :: hum

air relative hunidity (0-100)

real(kind=float), intent(in) :: temp

air temperature (degree celsius)

real(kind=float), intent(out) :: netRad

net radiation

private subroutine SetSpecificProperties(method, ini, mask)

set properties and initialize variables for each interpolation method

Arguments

Type IntentOptional Attributes Name
integer(kind=short), intent(in) :: method
type(IniList), intent(in) :: ini
type(grid_integer), intent(in) :: mask

private subroutine SkyView(dem, azimuth, view)

Compute the maximum angle of sky obstruction along 16 directions

Read more…

Arguments

Type IntentOptional Attributes Name
type(grid_real), intent(in) :: dem
real(kind=float), intent(in) :: azimuth(:)
type(ViewingAngle), intent(inout) :: view(:,:)